package com.bangyo.core.manager.impl;

import org.sothis.core.panelet.PaneletRequest;

import com.bangyo.core.manager.UserContext;

public class PaneletUserContext extends UserContext
{

    protected <F> PaneletUserContext(PaneletRequest<F> request)
    {
        if (null==request)
        {
            throw new NullPointerException(
                "Parameter [request] must be specified.");
        }
        setUserPoin(request.getSessionAttributeAsLong("userPoin", 0L));
        setSessionId(request.getSessionId());
        setRemoteAddress(request.getRemoteAddress());
        setUserAgentPermanentCode(request.getUserAgentPermanentCode());
    }

    public static <F> UserContext getUserContext(PaneletRequest<F> request)
    {
        return new PaneletUserContext(request);
    }
}
